<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>会员卡列表</title>
<link rel="stylesheet" href="${base}/images/contentImage/main.css" />
<script type="text/javascript" src="${base}/js/jquery-1.8.0.min.js"></script>

<script type="text/javascript" src="${base}/js/My97DatePicker4_8/WdatePicker.js"></script>
<link href="${base}/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/resources/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/js/list.js"></script>

 <!-- 引入弹出JS begin -->
<script type="text/javascript" src="${base}/js/lhgdialog/lhgdialog.min.js?self=true"></script>

<script>
$(document).ready(function(){
	var $deleteButton = $("#deleteButton")
	$deleteButton.unbind();
	$deleteButton.click( function() {
		var $this = $(this);
		if ($this.hasClass("disabled")) {
			return false;
		}
		var $checkedIds = $("#listForm input[name='ids']:enabled:checked");	
		
		$.dialog.confirm('是否确定删除?',function(){
			$.dialog.tips('会员卡删除中...',999999,'loading.gif');
			$.ajax({
				type: 'POST',
				dataType : "json",
				data:{"memberCardIdStr":getCheckBox()},
				url:  "${base}/memberCard/admin/deleteMemberCard.html",
				error: function (e) {//请求失败处理函数
					$.dialog.alert('请求失败！' + e); 				
				},
				success:function(data){ //请求成功后处理函数。 
					$.dialog.alert(data.result,function(){
						refreshIframe();
					});
				}
			});			
		},function(){},this);

	});
});

function getCheckBox(){	 
    var ids="";
    $("input[name='ids']:checked").each(function(){  
		ids += $(this).val()+",";
	});
    if (ids.length > 0) ids = ids.substring(0, ids.length-1);      
	return ids;
}

function addMemberCard(){
	var url = "${base}/memberCard/admin/addMemberCard.html";
	location.href = url;
}
function showMember(id){
	var url = "${base}/member/admin/showMember.html?memberId="+id;
	location.href = url;
}

function doConfirm(memberCardId,status) {
	var cfMsg = status ? "是否确定通过审核？" : "确定不通过审核？<br />该操作将删除会员卡与会员的关联信息";
	$.dialog.confirm(cfMsg,function(){
		$.dialog.tips('处理中...',999999,'loading.gif');
		$.ajax({
			type: 'POST',
			dataType : "json",
			data:{"memberCardId":memberCardId,status:status},
			url:  "${base}/memberCard/admin/doConfirm.html",
			error: function (e) {//请求失败处理函数
				$.dialog.alert('请求失败！' + e); 				
			},
			success:function(data){ //请求成功后处理函数。 
				if (data.msg != "true") {
					$.dialog.alert(data.msg,function(){
						refreshIframe();
					});
				} else {
					$.dialog.alert("操作成功",function(){
						refreshIframe();
					});
				}
			}
		});
	});
}

function refreshIframe(){
	$("#listForm").submit();
}
</script>
</head>

<body>
	<div class="path">会员卡管理&raquo; 会员卡列表</div>

	<form id="listForm" action="${base}/memberCard/admin/list.html" method="post">
		<!-- 隐藏域 begin-->

		<!-- 隐藏域 end-->
		<div class="bar">
			<a href="javascript:addMemberCard();" class="iconButton"> <span
				class="addIcon">&nbsp;</span>增加
			</a>

			<div class="buttonWrap">
				<a href="javascript:delMemberCard();" id="deleteButton" class="iconButton disabled">
					<span class="deleteIcon">&nbsp;</span>删除
				</a>
			</div>
			<div class="menuWrap">
				<div class="search">
					<span id="searchPropertySelect" class="arrow">&nbsp;</span> <input
						type="text" id="searchValue" name="searchValue"
						value="${searchValue!}" maxlength="200" />
					<button type="submit">&nbsp;</button>
				</div>
				<div class="popupMenu">
					<ul id="searchPropertyOption">
						<li><a href="#" <#if searchProperty??&&searchProperty=='memberCardCode'>class="current"</#if> val="memberCardCode">会员卡号 </a></li>
						<li><a href="#" <#if searchProperty??&&searchProperty=='memberName'>class="current"</#if> val="memberName">会员名称 </a></li>
					</ul>
				</div>
				<@s.pageBox page/>
				<div style="vertical-align: middle;padding: 2px 0;">
				审核状态:
					<select name="checkStatus" id="selCheckStatus">
						<option value="">全部</option>
						<option value="1" <#if checkStatus=='1'>selected</#if>>已绑定未审核</option>
						<option value="2" <#if checkStatus=='2'>selected</#if>>未绑定未审核</option>
						<option value="3" <#if checkStatus=='3'>selected</#if>>已绑定已审核</option>
					</select>
				</div>
			</div>

		</div>
		<table id="listTable" class="list">
			<tr>
				<th class="check"><input type="checkbox" id="selectAll" /></th>
				<th><a href="#">会员卡号</a></th>
				<th><a href="#">所绑定会员名称</a></th>
				<th><a href="#">操作</a></th> 

			</tr>

			<#if page.list??>
			<#list page.list as memberCard>
			<tr>
				<td><input type="checkbox" name="ids" value="${memberCard.memberCardId}"/></td>
				<td><span>${memberCard.memberCardCode}</span></td>
				<td>
					<#if memberCard.member != null>
					<span><a href="javascript:showMember(${memberCard.memberId});">${memberCard.member.loginName}</a></span>
					</#if>
				</td>
				<td>
					<#if memberCard.isValid == true>
						<font color="blue">已审核</font>
					<#else>
						<a href="javascript:doConfirm('${memberCard.memberCardId}',true);">审核通过</a>
					</#if>
					&nbsp;|&nbsp;
					<#if memberCard.isValid == true>
						<a href="javascript:doConfirm('${memberCard.memberCardId}',false);">取消审核</a>
					<#else>
					    <a href="javascript:doConfirm('${memberCard.memberCardId}',false);">审核不通过</a>
					</#if>
				</td>
			</tr>
			</#list> 
			</#if>
		</table>
		<#include "${rc.getContextPath()}/common/pagination.html"/>
	</form>


</body>
</html>
